package com.zp.crm.util.Logioiput;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.RandomAccessFile;


public class RandomInput {
	
	
	public void WriteString(String path,String obj){
		OutputStreamWriter pw = null;
		File file=new File(path);
		if(!file.exists()){
			try {
				pw = new OutputStreamWriter(new FileOutputStream(path),"UTF-8");
				pw.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		try {
			// 打开一个随机访问文件流，按读写方式
			RandomAccessFile randomFile = new RandomAccessFile(file, "rw");
			// 文件长度，字节数
			long fileLength = randomFile.length();
			// 将写文件指针移到文件尾。
			randomFile.seek(fileLength);
			byte[] b=obj.getBytes();
			randomFile.write(b);
			randomFile.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
	}
	
}
